const fileObject = {
  ppt: "application/vnd.ms-powerpoint;charset=utf-8",
  pptx: "application/vnd.openxmlformats-officedocument.presentationml.presentation;charset=utf-8",
  doc: "application/msword;charset=utf-8",
  docx: "application/vnd.openxmlformats-officedocument.wordprocessingml.document;charset=utf-8",
  xls: "application/vnd.ms-excel;charset=utf-8",
  xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8",
  pdf: "application/pdf;chartset=UTF-8",
};
export const downloadFileStream = (fileData, fileType, filename) => {
  const blob = new Blob([fileData], { type: fileObject[fileType] });
  console.log(blob, "blob");
  if ("download" in document.createElement("a")) {
    const link = document.createElement("a");
    link.download = filename;
    link.style.display = "none";
    link.href = URL.createObjectURL(blob);
    document.body.appendChild(link);
    link.click();
    URL.revokeObjectURL(link.href);
    document.body.removeChild(link);
  } else {
    navigator.msSaveBlob(blob, filename);
  }
};
